/*
 * @Description: 新增流程通用表单
 * @Author: Rfan
 * @Date: 2022-12-11 12:50:57
 * @LastEditTime: 2022-12-11 16:52:27
 */

import { Cascader, Form, Input, Select } from 'antd';
import { useFlowMgtContext } from '@/view/sysMaintenance/FlowMgt/contexts/FlowMgtContext';

interface IFlowFormProps {
  type: 'add' | 'edit';
}

const FlowForm = (props: IFlowFormProps) => {
  const { type } = props;
  const { processTypeFlatList } = useFlowMgtContext();
  const options = processTypeFlatList
    .filter((item) => item.pid && item.pid !== '0')
    .map((item) => ({ value: item.flowType, label: item.name }));

  return (
    <>
      <Form.Item name="modelType" label="流程类型">
        <Select options={options} />
        {/* <Cascader options={processTypeList} fieldNames={{ label: 'name', value: 'flowType' }} /> */}
      </Form.Item>
      <Form.Item name="name" label="流程名称">
        <Input allowClear />
      </Form.Item>
      {type === 'edit' && (
        <Form.Item name="processKey" label="流程KEY">
          <Input allowClear />
        </Form.Item>
      )}
      <Form.Item name="remark" label="备注">
        <Input.TextArea placeholder="备注信息描述，最多可填写2000字" maxLength={2000} showCount />
      </Form.Item>
    </>
  );
};

export default FlowForm;
